# coding: utf-8

from __future__ import absolute_import, division, print_function, unicode_literals

import os
from enum import Enum
from pathlib import Path


class OutFileType(Enum):
    init = 0
    http_client = 1
    http_route = 2
    http_model = 3
    rpc_client = 4
    rpc_model = 5


__OUT_FILE_NAME_MAP__ = {
    OutFileType.init: "__init__.py",
    OutFileType.http_client: "client.py",
    OutFileType.http_route: "route.py",
    OutFileType.http_model: "model.py",
    OutFileType.rpc_client: "client.py",
    OutFileType.rpc_model: "model.pyi"
}


def out_dir_path(root, psm):
    psm_str = psm.replace(".", "_")
    out = os.path.join(root, "api", psm_str)
    os.makedirs(out, exist_ok=True)
    return str(out)


def out_file_path(out_dir, out_type: OutFileType):
    out = os.path.join(out_dir, __OUT_FILE_NAME_MAP__[out_type])
    p = Path(str(out))
    p.touch(exist_ok=True)
    return str(out)
